package com.dianxin.smartpark.web.attendance;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.chinatelecom.response.common.CommonResponseBody;
import com.dianxin.smartpark.dao.qo.attendance.SmartParkAttendanceGroupQO;
import com.dianxin.smartpark.service.attendance.SmartParkAttendanceGroupService;
import com.dianxin.smartpark.service.vo.attendance.SmartParkAttendanceGroupVO;
import com.dianxin.sso.client.annotation.RecordLog;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 考勤组管理
 * @program: smart-park
 * @description: 考勤组管理
 * @author: chenyong
 * @create: 2021-07-30 11:34
 */
@RestController
@RequestMapping("/smartpark/attendance/attendanceGroup")
public class SmartParkAttendanceGroupController {

    @Resource
    private SmartParkAttendanceGroupService smartParkAttendanceGroupService;

    /**
     * 考勤组分页
     * @Description:  考勤组分页
     * @Author: ChenYong
     * @Date: 2021/7/30 0030
     * @param smartParkAttendanceGroupQO:
     * @Return: CommonResponseBody<List<SmartParkAttendanceGroupVO>>
     */
    @PostMapping("/getAttendanceGroups")
    @RecordLog(name = "考勤分组查询")
    @SaCheckPermission("/attendance/attendanceGroup/getAttendanceGroups")
    public CommonResponseBody<List<SmartParkAttendanceGroupVO>> getAttendanceGroups(@RequestBody SmartParkAttendanceGroupQO smartParkAttendanceGroupQO) {
        return smartParkAttendanceGroupService.getAttendanceGroups(smartParkAttendanceGroupQO);
    }

    /**
     * 保存考勤组
     * @Description:  保存考勤组
     * @Author: ChenYong
     * @Date: 2021/7/30 0030
     * @param smartParkAttendanceGroupQO:
     * @Return: CommonResponseBody<List<SmartParkAttendanceGroupVO>>
     */
    @PostMapping("/saveAttendanceGroup")
    @RecordLog(name = "考勤分组添加")
    @SaCheckPermission("/attendance/attendanceGroup/saveAttendanceGroup")
    public CommonResponseBody<List<SmartParkAttendanceGroupVO>> saveAttendanceGroup(@RequestBody SmartParkAttendanceGroupQO smartParkAttendanceGroupQO) {
        return smartParkAttendanceGroupService.saveAttendanceGroup(smartParkAttendanceGroupQO);
    }

    /**
     * 修改考勤组信息
     * @Description:  修改考勤组信息
     * @Author: ChenYong
     * @Date: 2021/7/30 0030
     * @param smartParkAttendanceGroupQO:
     * @Return: CommonResponseBody<List<SmartParkAttendanceGroupVO>>
     */
    @PostMapping("/updateAttendanceGroup")
    @RecordLog(name = "考勤分组修改")
    @SaCheckPermission("/attendance/attendanceGroup/updateAttendanceGroup")
    public CommonResponseBody<List<SmartParkAttendanceGroupVO>> updateAttendanceGroup(@RequestBody SmartParkAttendanceGroupQO smartParkAttendanceGroupQO) {
        return smartParkAttendanceGroupService.updateAttendanceGroup(smartParkAttendanceGroupQO);
    }

    /**
     * 根据ID获取考勤组信息详情
     * @Description: 根据ID获取考勤组信息详情
     * @Author: ChenYong
     * @Date: 2021/7/30 0030
     * @param smartParkAttendanceGroupQO: 根据ID
     * @Return: CommonResponseBody<List<SmartParkAttendanceGroupVO>>
     */
    @PostMapping("/attendanceGroupDetails")
    @RecordLog(name = "考勤分组详情")
    @SaCheckPermission("/attendance/attendanceGroup/attendanceGroupDetails")
    public CommonResponseBody<List<SmartParkAttendanceGroupVO>> attendanceGroupDetails(@RequestBody SmartParkAttendanceGroupQO smartParkAttendanceGroupQO) {
        return smartParkAttendanceGroupService.attendanceGroupDetails(smartParkAttendanceGroupQO);
    }

    /**
     * 根据ID删除考勤组信息
     * @Description: 根据ID删除考勤组信息
     * @Author: ChenYong
     * @Date: 2021/7/30 0030
     * @param ids: 根据ID
     * @Return: CommonResponseBody<List<SmartParkAttendanceGroupVO>>
     */
    @PostMapping("/deleteAttendanceGroup")
    @RecordLog(name = "考勤分组删除")
    @SaCheckPermission("/attendance/attendanceGroup/deleteAttendanceGroup")
    public CommonResponseBody<List<SmartParkAttendanceGroupVO>> deleteAttendanceGroup(@RequestBody Long[] ids) {
        return smartParkAttendanceGroupService.deleteAttendanceGroup(ids);
    }

    /**
     * 通过userId查询绑定的考勤组
     * @Description:  通过userId查询绑定的考勤组
     * @Author: ChenYong
     * @Date: 2021/9/2 0002
     * @param smartParkAttendanceGroupQO:
     * @Return: CommonResponseBody
     */
    @PostMapping("/getAttendanceGroupByUserId")
    @RecordLog(name = "通过userId查询绑定的考勤组")
    @SaCheckPermission("/attendance/attendanceGroup/getAttendanceGroupByUserId")
    public CommonResponseBody getAttendanceGroupByUserId(@RequestBody SmartParkAttendanceGroupQO smartParkAttendanceGroupQO){
        return smartParkAttendanceGroupService.getAttendanceGroupByUserId(smartParkAttendanceGroupQO);
    };
}
